package com.fh.fruit.service.activity.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.fh.dao.DaoSupport;
import com.fh.entity.Page;
import com.fh.fruit.entity.activity.ActivityLabel;
import com.fh.fruit.service.activity.ActivityLabelManager;
import com.fh.util.PageData;

/**
 * 区域商品详情Service
 * 
 * @author Administrator
 * @version 2017.11.30 15:39
 */
@Service("activityLabelService")
public class ActivityLabelService implements ActivityLabelManager {
	@Resource(name = "daoSupport")
	private DaoSupport dao;

	/**
	 * 获取活动标签
	* @author 葛欢欢
	* @version 2017.11.30 16:40 
	* @return
	* @throws Exception
	 */
	public List<ActivityLabel> getActivityLabel(Page page) throws Exception {
		// TODO Auto-generated method stub
		return (List<ActivityLabel>) dao.findForList("ActivityLabelManager.getActivityLabel",page);
	}

	/**
	  * 添加活动标签
	 * @author 葛欢欢
	 * @version 2017.11.30 16:40 
	 * @param activityLabel
	 * @return
	 * @throws Exception
	  */
	public int addActivityLabel(PageData pd) throws Exception {
		// TODO Auto-generated method stub
		ActivityLabel activityLabel = new ActivityLabel();
		activityLabel.setLabelCode(pd.getString("labelCode"));
		activityLabel.setLabelName(pd.getString("labelName"));
		activityLabel.setLabelPicHall(pd.getString("labelPicHall"));
		activityLabel.setLabelPicList(pd.getString("labelPicList"));
		return (int) dao.save("ActivityLabelManager.addActivityLabel", activityLabel);
	}

	/**
	  * 修改活动标签
	 * @author 葛欢欢
	 * @version 2017.11.30 16:40 
	 * @param activityLabel
	 * @return
	 * @throws Exception
	  */
	public int updateActivityLabel(PageData pd) throws Exception {
		// TODO Auto-generated method stub
		ActivityLabel activityLabel = new ActivityLabel();
		activityLabel.setLabelCode(pd.getString("labelCode"));
		activityLabel.setLabelName(pd.getString("labelName"));
		activityLabel.setCode(pd.getString("code"));
		activityLabel.setLabelPicHall(pd.getString("labelPicHall"));
		activityLabel.setLabelPicList(pd.getString("labelPicList"));
		return (int) dao.update("ActivityLabelManager.updateActivityLabel", activityLabel);
	}

	/**
	  * 删除活动标签
	 * @author 葛欢欢
	 * @version 2017.11.30 16:40 
	 * @param lableCode
	 * @return
	 * @throws Exception
	  */
	public int deleteActivityLabel(String lableCode) throws Exception {
		// TODO Auto-generated method stub
		return (int) dao.delete("ActivityLabelManager.deleteActivityLabel", lableCode);
	}

	@Override
	public ActivityLabel getActivityLabelByLabelCode(String labelCode) throws Exception {
		// TODO Auto-generated method stub
		return (ActivityLabel) dao.findForObject("ActivityLabelManager.getActivityLabelByLabelCode", labelCode);
	}

}
